/* eslint-disable react-refresh/only-export-components */
import { createBrowserRouter } from "react-router-dom";
import Login from "@/views/Login";
import Layout from "@/views/Layout";
import AuthRoute from "./modules/AuthRoute";
import { Suspense, lazy } from "react";


const Home = lazy(()=> import('@/views/Home'))
const FormPage = lazy(()=> import('@/views/FormPage'))
const TablePage = lazy(()=> import('@/views/TablePage'))
const Menu = lazy(()=> import('@/views/Menu'))
const Echarts = lazy(()=> import('@/views/Echarts'))
const Screen = lazy(()=> import('@/views/Screen'))
const MenuChild = lazy(()=> import('@/views/Menu/MenuChild.tsx') )


const router = createBrowserRouter([
  {
    path: "/",
    element: (
      <AuthRoute>
        <Layout />
      </AuthRoute>
    ),
    children: [
      {
        index: true,
        element: (
          <Suspense fallback={"加载中"}>
            
            <Home />
          </Suspense>
        ),
      },

      {
        path: "formpage",
        element: (
          <Suspense fallback={"加载中"}>
            <FormPage />
          </Suspense>
        ),
      },
      {
        path: "menu",
        element: (
          <Suspense fallback={"加载中"}>
            <Menu />
          </Suspense>
        ),
      },
      {
        path: "menuchild",
        element: (
          <Suspense fallback={"加载中"}>
            <MenuChild />
          </Suspense>
        ),
      },

      {
        path: "tablepage",
        element: (
          <Suspense fallback={"加载中"}>
            <TablePage />
          </Suspense>
        ),
      },
      {
        path: "echarts",
        element: (
          <Suspense fallback={"加载中"}>
            <Echarts />
          </Suspense>
        ),
      },
      {
        path: "screen",
        element: (
          <Suspense fallback={"加载中"}>
            <Screen />
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
]);

export default router;
